package com.xiaoshuidi.cloud.module.member.enums;

import cn.hutool.core.lang.Assert;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum MessageDestinationEnum {
    BROADCAST(1, "广播"),
    STEWARD(2, "管家个人"),
    TENANT(3, "租客个人");
    private Integer code;
    private String name;

    public static String getNameByCode(Integer code) {
        MessageDestinationEnum messageDestinationEnum = Arrays.stream(MessageDestinationEnum.values()).filter(p -> p.code.intValue() == code.intValue()).findFirst().orElse(null);
        Assert.isTrue(messageDestinationEnum != null, "MessageDestinationEnum:{}不存在", code);
        return messageDestinationEnum.getName();
    }
}
